﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using GeekShop.Properties;

namespace GeekShop.Commands.Transform
{
    public class Move : ICommand
    {
        #region Fields
        private Layer layer;
        private Size size;
        #endregion

        #region Contrustor
        public Move(Layer layer, Size size)
        {
            this.layer = layer;
            this.size = size;
        }
        public Move(Layer layer, Point location)
        {
            this.layer = layer;
            this.size = new Size(
                location.X - layer.Location.X,
                location.Y - layer.Location.Y);
        }
        #endregion

        #region Methods
        private void Action(Size size)
        {
            this.layer.Location = new Point(
                this.layer.Location.X + this.size.Width,
                this.layer.Location.Y + this.size.Height);
        }
        #endregion

        #region ICommand Members
        public void Do()
        {
            this.Action(this.size);
        }
        public void Undo()
        {
            this.Action(new Size(-this.size.Width, -this.size.Height));
        }
        #endregion
    }
}
